﻿Public NotInheritable Class Settings

    Private Sub Settings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'My.Settings.Reload()
        With My.Settings
            txtserver.Text = .Server
            txtdb.Text = .Database
            txttable.Text = .DBTable
            txtdbuser.Text = .DBUser
            txtdbpassword.Text = .DBPassword
            cbpersistinfo.Checked = .PersistSecurityInfo

            txthost.Text = .Host
            txtport.Text = .port
            txtsend.Text = .Sendpage
            txtmark.Text = .MarkPage

            txtmax.Text = .GetMaxMyItems
            txtdate.Text = .DateFromGetMyItems
            txtorderby.Text = .OrderBy
            cbread.Checked = .IncludeRead
            cbclose.Checked = .IncludeClose


            txtmyip.Text = .Myip
            txtmyname.Text = .MyNAme

            txtmymode.Text = .Mode
            txtrefresh.Value = .TimerDelay

            useRealtime.Checked = .UsePortToSendSignal
            txtRealPort.Text = .RealPort
        End With
        

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        With My.Settings
            .Server = txtserver.Text
            .Database = txtdb.Text
            .DBTable = txttable.Text
            .DBUser = txtdbuser.Text
            .DBPassword = txtdbpassword.Text
            .PersistSecurityInfo = cbpersistinfo.Checked

            .Host = txthost.Text
            .port = txtport.Text
            .Sendpage = txtsend.Text
            .MarkPage = txtmark.Text

            .GetMaxMyItems = txtmax.Text
            .DateFromGetMyItems = txtdate.Text
            .OrderBy = txtorderby.Text
            .IncludeRead = cbread.Checked
            .IncludeClose = cbclose.Checked


            .Myip = txtmyip.Text
            .MyNAme = txtmyname.Text
            .Mode = txtmymode.Text
            .TimerDelay = txtrefresh.Value

            .UsePortToSendSignal = useRealtime.Checked
            .RealPort = Integer.Parse(txtRealPort.Text)

        End With
        My.Settings.Save()
        Me.DialogResult = Windows.Forms.DialogResult.OK
        Me.Close()
        If MsgBox("Do you want to restart the Application?", vbYesNo) = MsgBoxResult.Yes Then
            Application.Restart()
        End If

    End Sub
End Class
